package com.ld.zxw.index;

import java.io.IOException;
import java.util.List;

import org.apache.log4j.Logger;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter;
import com.ld.zxw.config.Config;
import com.ld.zxw.config.IndexFactory;
import com.ld.zxw.util.CommonUtil;
import com.ld.zxw.util.DateUtil;
public class AddIndex implements IndexFactory{


	private Logger log = Logger.getLogger(AddIndex.class);
	
	@Override
	public boolean saveIndexs(Config config,List<Document> list) {
		long start_time = DateUtil.getTime();
		try {
			IndexWriter indexWriter = config.getIndexWriter();
			indexWriter.addDocuments(list);
			//刷新查询接口
			CommonUtil.refresh(config, indexWriter);
			DateUtil.timeConsuming("添加内核", start_time);
			return true;
		} catch (IOException e) {
			log.error("saveIndexs-error", e);
			return false;
		}
	}
}
